package com.ruoyi.informfrontend.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.informfrontend.mapper.ServiceArticleMapper;
import com.ruoyi.informfrontend.domain.ServiceArticle;
import com.ruoyi.informfrontend.service.IServiceArticleService;

/**
 * 服务资讯Service业务层处理
 *
 * @author ruoyi
 * @date 2023-05-17
 */
@Service
public class ServiceArticleServiceImpl implements IServiceArticleService
{
    @Autowired
    private ServiceArticleMapper serviceArticleMapper;

    /**
     * 查询服务资讯
     *
     * @param id 服务资讯主键
     * @return 服务资讯
     */
    @Override
    public ServiceArticle selectServiceArticleById(Long id)
    {
        /*增加浏览量*/
        serviceArticleMapper.updateNum(id);
        return serviceArticleMapper.selectServiceArticleById(id);
    }

    /**
     * 查询服务资讯列表
     *
     * @param serviceArticle 服务资讯
     * @return 服务资讯
     */
    @Override
    public List<ServiceArticle> selectServiceArticleList(ServiceArticle serviceArticle)
    {
        return serviceArticleMapper.selectServiceArticleList(serviceArticle);
    }

    /**
     * 新增服务资讯
     *
     * @param serviceArticle 服务资讯
     * @return 结果
     */
    @Override
    public int insertServiceArticle(ServiceArticle serviceArticle)
    {
        serviceArticle.setCreateTime(DateUtils.getNowDate());
        return serviceArticleMapper.insertServiceArticle(serviceArticle);
    }

    /**
     * 修改服务资讯
     *
     * @param serviceArticle 服务资讯
     * @return 结果
     */
    @Override
    public int updateServiceArticle(ServiceArticle serviceArticle)
    {
        serviceArticle.setUpdateTime(DateUtils.getNowDate());
        return serviceArticleMapper.updateServiceArticle(serviceArticle);
    }

    /**
     * 批量删除服务资讯
     *
     * @param ids 需要删除的服务资讯主键
     * @return 结果
     */
    @Override
    public int deleteServiceArticleByIds(Long[] ids)
    {
        return serviceArticleMapper.deleteServiceArticleByIds(ids);
    }

    /**
     * 删除服务资讯信息
     *
     * @param id 服务资讯主键
     * @return 结果
     */
    @Override
    public int deleteServiceArticleById(Long id)
    {
        return serviceArticleMapper.deleteServiceArticleById(id);
    }
}
